package com.wenchao.quickstart.base;

import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * @author Administrator
 */
public abstract class BaseFragment extends Fragment implements View.OnTouchListener {

    protected Context mContext;
    private View view;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        mContext = context;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        this.view = getView();
        initView(this.view);

        view.setFocusable(true);
        view.setFocusableInTouchMode(true);

        addListener();
        initData();
        view.setOnTouchListener(this);
    }

    public void initView(View view) {
    }

    public void addListener() {
    }

    public void initData() {
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        //消费掉点击事件,防止跑到下一层去
        return true;
    }
}
